#include <REGX52.H>
#include "Delay.h"

//STC12扩展板
#define KEY1 P0_0
#define KEY2 P0_1

//#define KEY1 P3_0
//#define KEY2 P3_1
#define KEY3 P3_2
#define KEY4 P3_3


/**
  * @brief  获取独立按键键码
  * @param  无
  * @retval 按下按键的键码，范围：0~4，无按键按下时返回值为0
  */
unsigned char Key()
{
	unsigned char KeyNumber=0;
	
	if(KEY1==0){Delay(20);while(KEY1==0);Delay(20);KeyNumber=1;}
	if(KEY2==0){Delay(20);while(KEY2==0);Delay(20);KeyNumber=2;}
	if(KEY3==0){Delay(20);while(KEY3==0);Delay(20);KeyNumber=3;}
	if(KEY4==0){Delay(20);while(KEY4==0);Delay(20);KeyNumber=4;}
	
	return KeyNumber;
}
